﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTOMall;
using System.Data;

namespace MallProject.Default
{
    public partial class Search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }
        public void LoadData() {
            ProductsDTO pDTO=new ProductsDTO();
            MoviesDTO mDTO = new MoviesDTO();
            string opt = Request.QueryString["opt"];
            string keyword=Request.QueryString["keyword"];
            //DataTable dt = new DataTable();
            if (opt.Equals("product")) {
                DataTable dt = pDTO.Search(keyword);
                if (dt.Rows.Count > 0)
                {
                    dtlpro.Visible = true;
                    dtlpro.DataSource = dt;
                    dtlpro.DataBind();
                }
                else {
                    Response.Write("Khong tim thay");
                }
            }else
            {
                DataTable dt1 = mDTO.Search(keyword);
                if (dt1.Rows.Count > 0)
                {
                    dtlMovie.Visible = true;
                    dtlMovie.DataSource = dt1;
                    dtlMovie.DataBind();
                }
                else
                {
                    Response.Write("Khong tim thay");
                }
            }
        }
    }
}